<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
</head>

<body>
    <template id="login">
        <div>{{msg}}</div>
    </template>
    <div id="app">
        <button @click="show">show</button>
        <!-- 用ref引入dom元素或者组件 -->
        <h3 ref="myh3">my h3</h3>
        <login ref="login"></login>
    </div>

    <script>
        Vue.component("login", {
            template: "#login",
            data() {
                return {
                    msg: "hahahaha"
                }
            },
            methods: {
                show() {
                    console.log("shjklhasjkfhsdjk")
                }
            }
        })
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {
                show() {
                    console.log(this.$refs.myh3.innerText)
                    console.log(this.$refs.login.msg)
                    this.$refs.login.show()
                }
            }
        });
    </script>
</body>

</html>